<!--
 * @Author: your name
 * @Date: 2021-08-13 15:49:01
 * @LastEditTime: 2021-11-05 14:41:43
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \jinfeng_up\src\components\seriousDelateDialog\seriousDelateDialog.vue
-->
<template>
  <div>
    <CommonDialog
      title="持续处理"
      width="75%"
      v-bind:dialogVisible="seriousDelateVisible"
      @on-change-dialogVisible="seriousDelateChange"
      top="5vh"
    >
      <template #body>
        <el-form
          class="seriousForm"
          ref="seriousForm"
          label-position="top"
          :model="seriousForm"
          :rules="seriousFormRules"
          size="mini"
          label-width="80px"
        >
          <el-row :gutter="10">
            <el-col :span="24">
              <el-form-item label="标题" prop="title">
                <el-input disabled v-model="seriousForm.title" class="changeHeight"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="12">
              <el-form-item label="反馈ID" prop="feedId">
                <el-input disabled v-model="seriousForm.feedId" class="changeHeight"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="创建天数" prop="createDay">
                <el-input disabled v-model="seriousForm.createDay" class="changeHeight"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="12">
              <el-form-item label="责任人" prop="currentStageUser">
                <el-input disabled v-model="seriousForm.currentStageUser" class="changeHeight"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="任务ID" prop="taskNumber">
                <el-input disabled v-model="seriousForm.taskNumber" class="changeHeight"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="24">
              <el-form-item label="当前进展" prop="currentProgress">
                <el-input type="textarea" v-model="seriousForm.currentProgress" class="continuousProcessing"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="24">
              <el-form-item label="下一步措施" prop="nextPlan">
                <el-input type="textarea" v-model="seriousForm.nextPlan" class="continuousProcessing"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <el-steps :space="180" :active="4">
          <el-step v-for="(item, index) in stageList" :key="index" :title="item.stageName"></el-step>
        </el-steps>
      </template>
      <template #dialog_footer>
        <el-button size="small" @click="seriousDelateVisible = false">关 闭</el-button>
        <el-button type="primary" @click="confrimSerious" size="small">保 存</el-button>
      </template>
    </CommonDialog>
  </div>
</template>

<script>
import CommonDialog from '@/components/commonDialog/commonDialog.vue'
import { FeedBack } from '@/api/feedBack/server'
export default {
    name: '',
    components: {
        CommonDialog
    },
    props: {},
    data() {
        return {
            //   会议ID
            meetingRecordId: '',

            //     反馈ID
            feedBackId: '',

            seriousDelateVisible: false,
            seriousForm: {
                title: '', // 标题
                feedId: '', // 反馈ID
                createDay: null, // 创建天数
                currentStageUser: '', // 责任人
                currentProgress: '', // 当前进展
                nextPlan: '', // 下一步计划
                problemType: '' // 问题类型
            },
            seriousFormRules: {
                currentProgress: [
                    {
                        required: true,
                        message: '请填写当前进展',
                        trigger: 'change'
                    }
                ],
                nextPlan: [
                    {
                        required: true,
                        message: '请填写下一步措施',
                        trigger: 'change'
                    }
                ]
            },

            //   阶段列表
            stageList: [],
            // 当前阶段
            stageNum: null
        }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
        seriousDelateChange(val) {
            this.seriousDelateVisible = val
            this.seriousForm = {
                title: '', // 标题
                feedId: '', // 反馈ID
                createDay: null, // 创建天数
                currentStageUser: '', // 责任人
                currentProgress: '', // 当前进展
                nextPlan: '', // 下一步计划
                problemType: '' // 问题类型
            }
        },

        show(string) {
            const row = JSON.parse(string)
            this.seriousDelateVisible = true
            this.seriousForm.feedId = row.feedBackId
            this.seriousForm.taskNumber = row.taskNumber
            this.meetingRecordId = row.meetingRecordId
            this.feedBackId = row.feedBackId
            this.getCreatorMessage(this.seriousForm.feedId)

            this.GetFeedBackStage(this.feedBackId)
        },

        /* 根据反馈ID获取相关信息 */
        async getCreatorMessage(id) {
            //   let id = this.feedBackNumber;
            try {
                const result = await FeedBack.GetFeedBackOverTime(id)
                if (result.success) {
                    this.seriousForm.createDay = result.data.createDay
                    this.seriousForm.title = result.data.title
                    this.seriousForm.currentStageUser = result.data.currentStageUser
                    this.seriousForm.problemType = result.data.problemType
                }
            } catch (err) {
                console.log(err)
            }
        },
        /**
     * @description:上会方法
     */
        async applicationApart() {
            const objparams = {
                currentProgress: this.seriousForm.currentProgress,
                id: this.meetingRecordId,
                nextPlan: this.seriousForm.nextPlan
            }

            try {
                const result = await FeedBack.Pocessing(objparams)

                if (result.success) {
                    this.seriousForm = {
                        title: '', // 标题
                        feedId: '', // 反馈ID
                        createDay: null, // 创建天数
                        currentStageUser: '', // 责任人
                        currentProgress: '', // 当前进展
                        nextPlan: '', // 下一步计划
                        problemType: '' // 问题类型
                    }
                    this.$emit('refreshPage')
                    this.seriousDelateVisible = false
                }
            } catch (err) {
                console.log(err)
            }
        },
        confrimSerious() {
            this.$refs['seriousForm'].validate(valid => {
                if (valid) {
                    this.applicationApart()
                } else {
                    return false
                }
            })
        },

        // 获取阶段
        async GetFeedBackStage() {
            try {
                const result = await FeedBack.GetFeedBackStage(this.feedBackId)

                if (result.success) {
                    this.stageList = result.data
                    this.stageNum = this.stageList.length
                    this.$emit('refreshPage')
                }
            } catch (err) {
                console.log(err)
            }
        }
    }
}
</script>

<style scoped lang="less">
::v-deep .el-input--mini .el-input__inner {
  height: 35px;
}
changeHeight {
  height: 30px;
}

::v-deep .continuousProcessing textarea {
  height: 150px;
  background: #ffffff;
  border: 1px solid #dadee0;
  border-radius: 2px;
}
</style>
